package application;

import java.util.StringTokenizer;
import network.*;
import link.*;

public class UserInterface implements Runnable {

	public void run() {
		System.out.println("enter \"help\" for a list of the commands");
		while (true) {
			System.out.print("> ");
			StringTokenizer st = new StringTokenizer(Keyboard.readString(), " ");
			String cmd = st.nextToken();
			if (cmd.equals("help")) {
				System.out.println("\tack [target]: initiate ack exchange");
				System.out.println("\tnack : initiate Nack exchange");
				System.out
						.println("\telection: initiate an election (you will need to have chosen a integer as name)");
				System.out.println("\troute: print out the routing table");
				System.out.println("\texit : exit");
			} else if (cmd.equals("tack")) {

			} else if (cmd.equals("exit")) {
				break;
			} else if (cmd.equals("ack")) {
				// String to = st.nextToken();
				// String msg = "server:dummy:addroute:" + to + ":" + from +
				// ":";
				// s.send(msg);
			} else if (cmd.equals("nack")) {
				// String to = st.nextToken();
				// String msg = "server:dummy:addroute:" + to + ":" + from +
				// ":";
				// s.send(msg);
			} else if (cmd.equals("election")) {

			} else if (cmd.equals("route")) {
				NetworkLayer.showTable();
			} else {
				System.out.println("\n Unknown Command \n");
			}
			try {
				Thread.sleep(150);
			} catch (Exception e) {
			}
		}
		System.exit(0);
	}
}
